﻿// <copyright file="Scenes.cs" company="Ucaya">
// </copyright>
// <author>Ucaya</author>

namespace MediaRss
{
    #region

    using System.Xml;
    using System.Xml.Linq;
    using System.Xml.Serialization;

    #endregion

    [XmlRoot(ElementName = "scenes", Namespace = "http://search.yahoo.com/mrss/")]
    public class Scenes : MediaRssBase, IXmlSerializable
    {
        #region Constants and Fields

        internal const string ELEMENT_NAME = "scenes";

        #endregion

        #region Public Methods

        public void ReadXml(XmlReader reader)
        {
            bool isEmptyElement = reader.IsEmptyElement;
            base.AddAttributeExtensions(reader);
            reader.ReadStartElement();
            if (!isEmptyElement)
            {
                while (reader.IsStartElement())
                {
                    base.ElementExtensions.Add((XElement)XNode.ReadFrom(reader));
                }
            }
            reader.ReadEndElement();
        }

        public void WriteXml(XmlWriter writer)
        {
            foreach (var pair in base.AttributeExtensions)
            {
                writer.WriteAttributeString(pair.Key.Name, pair.Key.Namespace, pair.Value);
            }
            foreach (var element in base.ElementExtensions)
            {
                element.WriteTo(writer);
            }
        }

        #endregion
    }
}